Original author(s) | Brian Fox |
---|---|
Developer(s) | Chet Ramey |
Initial release | 1989 |
Stable release | 6.2 (February 14, 2011 )[1] [±] |
Written in | C |
Operating system | Various |
Type | Library |
License | GNU General Public License |
Website | Official website |
GNU readline is a software library that provides line-editing and history capabilities for interactive programs with a command-line interface, such as Bash. It is currently maintained by Chet Ramey as part of the GNU Project.
It allows users to move the text cursor, search the command history, control a kill ring (a more flexible version of a copy/paste clipboard) and use tab completion on a text terminal.
Readline key bindings are taken from the text editor Emacs, but can be customized. As a cross-platform library, readline allows applications on various systems to exhibit identical line-editing behavior.
Contents |
GNU Readline is notable for being a free software library which is licensed under the GNU General Public License (GPL) instead of the GNU Lesser General Public License (LGPL). Free software libraries are often licensed under the LGPL, for example, the GNU C Library, GNU gettext and FLTK.
A developer of an application who chooses to link to an LGPL licensed library when building a new application is required to have the LGPL licensed library which it uses remain under the LGPL when distributing the combined resulting application. The part of the combined application excluding the LGPL licensed library can remain under the original license.[2] This is in contrast to a developer choosing to use a GPL licensed library to create a new application, in which case the entire combined resulting application is required to be licensed under the GPL when distributed, to comply with section 5 of the GPL.[3][4]
This type of reciprocal licensing scheme is generally known as copyleft (more precisely the GPL and the LGPL are examples of strong and weak copyleft licenses respectively), and has ramifications for readline's integration into free software applications whose licences don't have any copyleft provisions (these licenses are usually referred to as permissive licenses).
Licensing GNU Readline under a a strong copyleft license like the GPL means that, if a developer of an application chooses to link that application with the readline library, they are obligated to change the license of the resulting application to the GPL if they wish to distribute the resulting application.
An important example of an application changing its licensing to comply with the copyleft conditions of GNU Readline is CLISP, an implementation of Common Lisp. Originally released in 1987, it changed to the GPL license in 1992,[5] after an email exchange between one of CLISP's original author's, Bruno Haible, and Richard Stallman, in which Stallman argued[6] that the linking of readline in CLISP meant that Haible was required to re-license CLISP under the GPL if he wished to distribute the implementation of CLISP which used readline.[7]
Since its initial release, some developers of permissively licensed software who have wanted to use the GNU readline library in their applications have occasionally expressed their annoyance[8] with the licensing conditions of readline on development mailing lists. Other developers have responded by stating that this is a waste of time.[9]
Alternative command line editing libraries which are permissively licensed can be used by software projects which want to implement command line editing functionality, but wish to remain under a permissive license. For example the Glasgow Haskell Compiler uses Haskeline (which is licenced under the 3 clause BSD license). Similar libraries are listed in the external links.
The following code is in C :
#include <stdlib.h> #include <stdio.h> #include <unistd.h> #include <readline/readline.h> #include <readline/history.h> int main() { char* input, shell_prompt[100]; for(;;) { // getting the current user 'n path snprintf(shell_prompt, sizeof(shell_prompt), "%s:%s $ ", getenv("USER"), getcwd(NULL, 1024)); // inputing... input = readline(shell_prompt); // eof if (!input) break; // path autocompletion when tabulation hit rl_bind_key('\t', rl_complete); // adding the previous input into history add_history(input); /*do stuff*/ } }
|